var vm = new Vue({
    el: '#aglorithManage',
    data: {
        "stringRule": true,
        "stringRuleColor": "blue",
        "Keyword": false,
        "KeywordColor": "black",
        "generalRule": false,
        "generalColor": "black",
        "changeRule": false,
        "changeRuleColor": "black",
        "stringRuleModel": {
            "remainBeforeEnd": {
                "id": 1,
                "n": 3,
                "m": 4
            },
            "remainFromTo": {
                "id": 1,
                "x": 3,
                "y": 4
            },
            "coverBeforeEnd": {
                "id": 1,
                "n": 3,
                "m": 4
            },
            "coverFromTo": {
                "id": 1,
                "x": 3,
                "y": 4
            },
            "beforeChar": {
                "id": 1,
                "value": 1
            },
            "afterChar": {
                "id": 1,
                "value": 1
            }
        },
        "options": [{
            value: '1',
            label: '向左'
        }, {
            value: '2',
            label: '向右'
        }]
    },
    computed: {
        getstringRuleModel :function(){
            //todo 调用初始化接口.
        }
    },
    methods: {
        clickStringRule: function (event) {
            this.stringRule = true;
            this.Keyword = false;
            this.generalRule = false;
            this.changeRule = false;
            this.stringRuleColor = "blue";
            this.KeywordColor = "black";
            this.generalColor = "black";
            this.changeRuleColor = "black";
        },
        clickKeyWord: function (event) {
            this.Keyword = true;
            this.stringRule = false;
            this.generalRule = false;
            this.changeRule = false;
            this.KeywordColor = "blue";
            this.stringRuleColor = "black";
            this.generalColor = "black";
            this.changeRuleColor = "black";
        },
        clickGeneralRule: function () {
            this.Keyword = false;
            this.stringRule = false;
            this.generalRule = true;
            this.changeRule = false;
            this.KeywordColor = "black";
            this.stringRuleColor = "black";
            this.generalColor = "blue";
            this.changeRuleColor = "black";
        },
        clickchangeRule: function () {
            this.Keyword = false;
            this.stringRule = false;
            this.generalRule = false;
            this.changeRule = true;
            this.KeywordColor = "black";
            this.stringRuleColor = "black";
            this.generalColor = "black";
            this.changeRuleColor = "blue";
        },
        saveBeforeChar: function (index) {
            //构建初始化数组.
            var array = [];
            for (var key  in this.stringRuleModel) {
                array.push(this.stringRuleModel[key]);
             }
            var numToSave = array[index];
            //todo 调用接口进行保存.
            $.ajax({
                type: "GET",
                contentType: 'application/json',
                dataType: "json",
                async: false,
                url: "commonapi/region",
                success: function (jsonData) {
                    if (jsonData.code == 200) {
                        ChineseDistricts = jsonData.map;
                    }
                }
            });
            console.log(index);
            console.log(this.stringRuleModel.beforeChar);
        }

    }
});